home *** CD-ROM | disk | FTP | other *** search
- /* 86WORLD Figure 11 - DisplayChar()
- Micro Cornucopia Magazine Issue #46 */
-
- /*-- Crudely display a character of a font --*/
-
- void DisplayChar(unsigned char ch, char* bitmap, int Height,
- int BitMapWidth, int chofstable[])
- {
- printf("char: %02x, %d bits wide\n", ch, chofstable[ch+1]-chofstable[ch]);
- int const bitoffset = (chofstable[ch] & 7);
- bitmap += chofstable[ch] >> 3; /* byte offset of start of char */
-
- for (int r = 0; r < Height; r++)
- {
- char* ptr = bitmap;
- char workbyte = (*ptr++) << bitoffset;
- int bcount = (7 - bitoffset);
- for (int bitstoprint = chofstable[ch+1] - chofstable[ch];
- bitstoprint > 0; bitstoprint--)
- {
- putchar(workbyte & 0x80 ? '*':'.');
- workbyte <<= 1;
- if (!bcount--)
- {
- workbyte = *ptr++;
- bcount = 7;
- }
- } /* for b */
- putchar('\n');
- bitmap += BitMapWidth;
- } /* for r */
- } /* DisplayChar */
-
- /*-------------------------------------------------------------------*/
- main( int argc, char* argv[ ] )
- { /* print all chars in Gem Font file given on command line */
- ReadGemFont(argv[1]);
- for (int ch = 0; ch <= GemFont.gfLastChar - GemFont.gfFirstChar; ch++)
- DisplayChar(ch, bitmap, GemFont.gfFormHeight,
- GemFont.gfFormWidth, chofstable);
- printf("Done.\n");
- }
-